Export rtf as pdf file

Hello,

I experience some problem exporting a .rtf file as a .pdf file.

 

To get it simple, I get a "C:\test.rtf" file.

I want to get a converted file C:\test.pdf" file using the Word "Save as pdf" feature.

 

I followed some instructions here

https://www.ibm.com/developerworks/community/forums/html/topic?id=0ea92dad-acce-46d6-97c5-511d632f8841

 

And I get this following code but it's not working...

The rtf file is opening but nothing moreWhat am I doing wrong?

 

OleAutoObj objWord = oleCreateAutoObject("Word.Application")
olePut(objWord, "Visible", true)
OleAutoObj objDoc = null
oleGet(objWord, "Documents", objDoc)
OleAutoArgs args = create()

string docName="C:\\DOCS\\test.rtf"
put(args, docName)
oleMethod(objDoc, "Open", args)
clear args

 

OleAutoArgs oaaArgs = create
put(oaaArgs, "OutputFileNamea", "C:\\test.pdf")   // full windows path of desired output file name
put(oaaArgs, "ExportFormat",   17)  // constant value is 17
oleMethod(objDoc, "ExportAsFixedFormat", oaaArgs)

 

 

Thank you very much for your help!!!


ducosa - Mon Sep 05 05:55:55 EDT 2016

Re: Export rtf as pdf file
DOORSHAM - Tue Sep 06 08:09:18 EDT 2016

Line OleAutoArgs oaaArgs = create  creates a new document but you never loaded the rtf in the new document.

 

 

Re: Export rtf as pdf file
ducosa - Fri Sep 09 10:43:47 EDT 2016

Thank you for answering me!

 

I still don't get it, opening the document is done through the oleMethod, not the args?

I mean, for me oleMethod(objDoc, "Open", args) declare objDoc as the open document.

Then objDoc can be used at the last line with other arguments

 

Of course It looks like I'm wrong but hell I just can't understand :D

 

Thank you!

 

Regards,

 

Antoine

Re: Export rtf as pdf file
DOORSHAM - Mon Sep 12 13:45:59 EDT 2016

You can hope someone will translate the following vba to DXL.

Sub SaveAsPDF()
    ActiveDocument.ExportAsFixedFormat OutputFileName:="c:\test.pdf", _
        ExportFormat:=wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub

Re: Export rtf as pdf file
chmari - Mon Sep 19 06:15:43 EDT 2016

Hi,

The solution in DXL:

OleAutoObj objWord = oleCreateAutoObject("Word.Application")
olePut(objWord, "Visible", true)
OleAutoObj objDocs = null
oleGet(objWord, "Documents", objDocs)
OleAutoArgs args = create()

string docName="D:\\Temp\\test.rtf"
put(args, docName)
OleAutoObj objDoc
oleMethod(objDocs, "Open", args, objDoc)
clear args

args = create
put(args, "D:\\Temp\\test.pdf")
put(args, 17)
print oleMethod(objDoc, "ExportAsFixedFormat", args)
oleMethod(objDoc, "Close")
oleMethod(objWord, "Quit")

 

Regards

Christophe